<template>
	<view class="more">
		<view class="kong" v-if="list.length==0">
			<view @click="ortherCode">
				<image src="@/static/kong.png" mode="widthFix"></image>
				<text>功能开发中~</text>
			</view>
		</view>
		<view class="programList">
			<view class="programBox" v-for="(item,index) in list" :key="index" @click="ortherCode(item.program_appid,item.program_router)">
				<view class="programBoxLeft">
					<image :src="imageUrl+item.program_image" mode="widthFix"></image>
					<text>{{item.program_name}}</text>
				</view>
				<view class="programBoxRight">
					<image src="@/static/right.png" mode="widthFix"></image>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	var _this
	export default {
		data() {
			return {
				imageUrl:"",
				list:[],
				appid:""
			};
		},
		onShow(){
			_this = this
			_this.imageUrl = _this.$imageUrl
			_this.appid = uni.getAccountInfoSync().miniProgram.appId
			_this.programList()
		},
		methods:{
			programList: async function(){
				await _this.$api.programList(res=>{
					// console.log(res)
					_this.list = res.data
					let index = _this.list.findIndex(item => item.program_appid === _this.appid);
					_this.list.splice(index, 1);
				})
			},
			ortherCode(appId,path){
				wx.navigateToMiniProgram({
				    appId: appId, // 替换为目标小程序 AppID
				    path: path, // 小程序路径
				    envVersion: 'release', // 开发版、体验版或正式版
				    success(res) {
						console.log("跳转到其他小程序成功！", res);
				    },
				    fail(err) {
				        console.error("跳转到其他小程序失败！", err);
				    }
				});
			}
		}
	}
</script>

<style lang="scss">
	page{
		width: 100vw;
		overflow: hidden;
		box-sizing: border-box;
	}
	.more{
		background-color: #f8f8f8;
		min-height: 100vh;
		padding: 32rpx;
		box-sizing: border-box;
		.kong{
			display: flex;
			align-items: center;
			justify-content: center;
			width: 100vw;
			height: 100vh;
			box-sizing: border-box;
			image{
				width: 200rpx;
				display: block;
				margin-bottom: 12rpx;
			}
			text{
				display: block;
				text-align: center;
				color: #BDC1CB;
			}
		}
		.programList{
			.programBox{
				background-color: #fff;
				border-radius: 24rpx;
				margin-bottom: 24rpx;
				display: flex;
				justify-content: space-between;
				align-items: center;
				padding: 24rpx;
				.programBoxLeft{
					display: flex;
					align-items: center;
					gap: 0 24rpx;
					image{
						width: 62rpx;
						border-radius: 62rpx;
					}
				}
				.programBoxRight{
					image{
						width: 32rpx;
					}
				}
			}
		}
	}
</style>
